#include <stdio.h>
#include "speexEC.h"

#define NN 160

short ref[NN], mic[NN], out[NN];
	
int main(int argc, char **argv)
{
	FILE* ref_fd, *mic_fd, *out_fd;
	ref_fd = fopen ("ref.pcm", "rb");//打开参考文件，即要消除的声音
	mic_fd = fopen ("mic.pcm", "rb");//打开mic采集到的声音文件，包含回声在里面
	out_fd = fopen ("echo.pcm", "wb");//消除了回声以后的文件

	CSpeexEC ec;
	ec.Init(500, 500*8, 16000);
 
	while (fread(mic, 1, NN*2, mic_fd))
	{
		fread(ref, 1, NN*2, ref_fd); 
		ec.DoAEC(mic, ref, out);
		fwrite(out, 1, NN*2, out_fd);
	}
 
	fclose(ref_fd);
	fclose(mic_fd);
	fclose(out_fd);
	
	return 0;
}
